package com.zw.vo;

import com.zw.utils.Retcode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

/**
 * @author ZhangWu, Anything is possible!
 * @date 2022/3/31 8:53
 * @description
 */
@Data
@Builder
@AllArgsConstructor
@ApiModel(description = "统一返回对象")
public class ResponseVO<T> {
    /**
     * 返回码
     */
    @ApiModelProperty(value = "状态码")
    private String retcode;
    /**
     * 返回信息
     */
    @ApiModelProperty(value = "返回信息")
    private String retmsg;
    /**
     * 返回数据
     */
    @ApiModelProperty(value = "返回数据")
    private T data;

    /**
     * 返回成功构造函数
     * @param data
     */
    public ResponseVO(T data) {
        this.retcode = Retcode.SUCCESS.code();
        this.retmsg = Retcode.SUCCESS.msg();
        this.data = data;
    }

    /**
     * 返回系统异常的构造函数
     */
    public ResponseVO() {
        this.retcode = Retcode.SYSTEM_EXCEPTION.code();
        this.retmsg = Retcode.SYSTEM_EXCEPTION.msg();
        this.data = null;
    }
}